//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "server\fn_serverSetupTakeOverCheck.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_parameters","_params","_id","_result"];
_parameters = _this;
_result = false;
if (IS_ARRAY(_parameters) && {count _parameters > 2}) then {
	_id = GETVAL(_parameters,0,"");
	_params = GETVAL(_parameters,2,[]);
	TRACE_1("Extracted",ARR_2(_id,_params));
	if (IS_ARRAY(_params) && {count _params > 0}) then {
		private ["_object","_action_id"];
		_object = GETVAL(_params,0,objNull);
		_action_id = GETVAL(_params,1,0);
		TRACE_1("Checking",ARR_2(_object,_action_id));
		if (!(isNull _object)) then {
			private ["_action","_status"];
			_action = [_object,_action_id] call FFUNC(actionGet);
			_status = [_object,_action,"TAKEOVER_KILLED_STATUS",-1] call FFUNC(actionGetLocal);
			_result = (alive _object && (_status <= 0));
			TRACE_1("Checked",ARR_2(_object,_status));
		};
	};
} else {
	TRACE_1("Missing Parameter");
};
TRACE_1("End",_result);
TMFPROFILERSTOP;
_result;